<?php
	require_once("../classes/Database.php");
	require_once("../classes/User.php");
	
	session_start();
	
	$db = new Database("localhost", "root", "");
	$user = $_SESSION["user"];
	
	$id = $user->getId();
	$category = $_POST["category"];
	$description = $_POST["description"];
	
	$db->connect("emprego");
	$db->executeQuery("SELECT * FROM curriculum WHERE id='$id'");
	if($line = $db->getResultLine(MYSQL_ASSOC)){
		$db->executeQuery("UPDATE curriculum SET category='$category', description='$description' WHERE id='$id'");
	}else{
		$db->executeQuery("INSERT INTO curriculum(id, category, description) VALUES('$id', '$category', '$description')");
	}
	
	header("Location: ../createCV.php");
?>
